package org.abacus.platform.client.widget;

import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JTextField;

import org.abacus.platform.client.action.Input;

public class Text extends Widget implements Input {
	public final static int FIELD_WIDTH = 230;
	public final static int FIELD_HEIGHT = 25;
	public final static String COLON = ":";
	final JTextField field;
	final JLabel label;

	public Text(String label) {
		super();
		this.field = new JTextField();
		this.label = new JLabel(label + COLON);
		this.initField();
	}

	@Override
	public Object getText() {
		return field.getText();
	}

	public JTextField getField() {
		return field;
	}

	private void initField() {
		Dimension preferredSize = new Dimension(FIELD_WIDTH, FIELD_HEIGHT);
		field.setPreferredSize(preferredSize);
		field.setBorder(BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
		field.setLayout(new BorderLayout(0, 0));
	}
}
